<template>
  <!-- 底部部分 -->
  <footer class="footer">
    <span class="todo-count"
      ><strong>{{ list.length }}</strong
      >剩余</span
    >
    <ul class="filters" @click="xuan(type)">
      <li>
        <a @click="type = 'all'" :class="{ selected: type === 'all' }" href="#/"
          >全部</a
        >
      </li>
      <li>
        <a
          @click="type = 'on'"
          :class="{ selected: type === 'on' }"
          href="#/active"
          >进行中</a
        >
      </li>
      <li>
        <a
          @click="type = 'yes'"
          :class="{ selected: type === 'yes' }"
          href="#/completed"
          >已完成</a
        >
      </li>
    </ul>
    <button v-show="show" @click="clear" class="clear-completed">
      清除已完成
    </button>
  </footer>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {
      type: "all",
    };
  },
  methods: {
    clear() {
      console.log(this.type);
      this.$emit("hclear");
    },
    xuan(type){
        this.$emit('hxuan',type)
    }
  },
  computed: {
    show() {
      return this.list.some((itme) => itme.isDone);
    },
  },
};
</script>

<style>
</style>